﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using SharedGenomics.Core;
using SharedGenomics.Workbench.Core;
using SharedGenomics.Workbench.Views;

namespace SharedGenomics.Workbench.Presenters
{
    public class MainFormPresenter : Presenter, IMainFormPresenter
    {
        public MainFormPresenter(IMainFormView view, IMenuBarMenuFactory menuBarMenuFactory, CommandFactory commandFactory)
            : base(view)
        {

            this.MainView = view;
            this.InitialiseMenuBar(menuBarMenuFactory, commandFactory);
        }

        private void InitialiseMenuBar(IMenuBarMenuFactory menuFactory, CommandFactory commandFactory)
        {
            //create options menu
            IMenuBarMenu optionsMenu = menuFactory.CreateMenu("Options");

            //add annotations menu
            ICommand annotationOptionsCommand = commandFactory.CreateOpenPresenterAnnotationCommand<AnnotationOptionsPresenter>(FormDisplayMode.NonModalDialog, null, null);
            IMenuBarMenu annotationsMenu = menuFactory.CreateMenu("Annotations", annotationOptionsCommand);

            //add annotation menu to options and then add to main view menu bar
            optionsMenu.AddSubMenu(annotationsMenu);
            this.MainView.AddMenuBarMenu(optionsMenu);
        }

        private IMainFormView MainView { get; set; }

        public void SetMainView(IView view)
        {
            this.MainView.MainView = view;
        }

        public void SetMainMenu(IMenu menu)
        {
            this.MainView.Menu = menu;
        }
    }
}
